jQuery(document).ready(function($){

/* Latest News and Testiminials scroller */
 	jQuery('#latest-news ul').cycle({ 
	    fx: 'scrollVert',
		speed: 650,
		rev: true,
		timeout: 10000,
		next:   '#latest-news ol li.next', 
	    prev:   '#latest-news ol li.previous'
	 });      
		
	jQuery('#testimonials ul').cycle({ 
	   fx: 'scrollVert',
		speed: 650,
		rev: true,
		timeout: 10000,
		next:   '#testimonials ol li.next', 
	    prev:   '#testimonials ol li.previous'
	});
 
  /* initialize prettyphoto */
  $("a[rel^='prettyPhoto']").prettyPhoto({
		theme: 'light_square'
  });

  $('.toggle .toggle_content:first').show();
	$(".toggle_title").toggle(
		function(){
			$(this).addClass('toggle_active');
			$(this).siblings('.toggle_content').slideDown("fast");
		},
		function(){
			$(this).removeClass('toggle_active');
			$(this).siblings('.toggle_content').slideUp("fast");
		}
	);

	$(".tabs_container").each(function(){
		$("ul.tabs",this).tabs("div.panes > div", {tabs:'li',effect: 'fade', fadeOutSpeed: -400});
	});
	$(".mini_tabs_container").each(function(){
		$("ul.mini_tabs",this).tabs("div.panes > div", {tabs:'li',effect: 'fade', fadeOutSpeed: -400});
	});
	$.tools.tabs.addEffect("slide", function(i, done) {
		this.getPanes().slideUp();
		this.getPanes().eq(i).slideDown(function()  {
			done.call();
		});
	});


  $('#buttonsend').click( function() {
	
		var name    = $('#name').val();
		var subject = $('#subject').val();
		var email   = $('#email').val();
		var message = $('#message').val();
		var siteurl = $('#siteurl').val();
		
		$('.loading').fadeIn('fast');
		
		if (name != "" && subject != "" && email != "" && message != "")
			{

				$.ajax(
					{
						url: siteurl+'/sendemail.php',
						type: 'POST',
						data: "name=" + name + "&subject=" + subject + "&email=" + email + "&message=" + message,
						success: function(result) 
						{
							$('.loading').fadeOut('fast');
							if(result == "email_error") {
								$('#email').css({"border":"1px solid #FF8C8C"}).next('.require').html('<small>invalid e-mail address</small> !');
							} else {
								$('#name, #subject, #email, #message').val("");
								$('#emailSuccess').show().fadeOut(6000, function(){ $(this).remove(); });
							}
						}
					}
				);
				return false;
				
			} 
		else 
			{
				$('.loading').fadeOut('fast');
				if( name == "") $('#name').css({"border":"1px solid #FF8C8C"}).next('.require').text(' !');
				if(subject == "") $('#subject').css({"border":"1px solid #FF8C8C"}).next('.require').text(' !');
				if(email == "" ) $('#email').css({"border":"1px solid #FF8C8C"}).next('.require').text(' !');
				if(message == "") $('#message').css({"border":"1px solid #FF8C8C"}).next('.require').text(' !');
				return false;
			}
	});
	
		$('#name, #subject, #email,#message').focus(function(){
			$(this).css({"border":"1px solid #dcdcdc"}).next('.require').text(' *');
		});
      	
           
});
